
#include <LiquidCrystal.h>//we must include this code for LCD operating
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//code for LCD
int const potPin = A0; //input from potentiometer
int potVal;
float angle;
float maxx=0;
int s;
void setup() {
  Serial.begin(9600);
  lcd.begin(16,2); //code for LCD
  lcd.print("The angle is");//code for LCD
  pinMode(6,INPUT);
}


void loop(){
  s=digitalRead(6);
potVal = analogRead(potPin);
  angle = map(potVal,51,708,0,180);//this is convert the value from arduino to angle
  // this is maximum angle function
  if (angle > maxx) {
    maxx = angle;
  }
  Serial.println(maxx);// this is print the sesult in display
  if(s==1){
  lcd.setCursor(0,1);//code for LCD
   lcd.println(maxx,1);}//code for LCD
    if(s==0){
  lcd.setCursor(0,1);//code for LCD
   lcd.println(angle,1);}//code for LCD
  delay(10);
  
  
}

  
  